/**
 * Copyright &copy; 2012-2016 <a href="https://www.kaaction.com">KAA</a> All rights reserved All rights reserved.
 */
package com.kaaction.modules.mer.service;

import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.kaaction.common.persistence.Page;
import com.kaaction.common.service.CrudService;
import com.kaaction.modules.mer.entity.WeddingProcess;
import com.kaaction.modules.mer.dao.WeddingProcessDao;

/**
 * 婚礼流程Service
 * @author huanghaiming
 * @version 2017-06-02
 */
@Service
@Transactional(readOnly = true)
public class WeddingProcessService extends CrudService<WeddingProcessDao, WeddingProcess> {

	public WeddingProcess get(String id) {
		return super.get(id);
	}
	
	public List<WeddingProcess> findList(WeddingProcess weddingProcess) {
		return super.findList(weddingProcess);
	}
	
	public Page<WeddingProcess> findPage(Page<WeddingProcess> page, WeddingProcess weddingProcess) {
		return super.findPage(page, weddingProcess);
	}
	
	@Transactional(readOnly = false)
	public void save(WeddingProcess weddingProcess) {
		super.save(weddingProcess);
	}
	
	@Transactional(readOnly = false)
	public void delete(WeddingProcess weddingProcess) {
		super.delete(weddingProcess);
	}

	@Transactional(readOnly = false)
	public void insOrUpdWeddingProcess(WeddingProcess weddingProcess) {
		
		int cnt = super.dao.selCnt(weddingProcess.getThirdpartyId());
		
		if(cnt==0){
			weddingProcess.preInsert();
			super.dao.insert(weddingProcess);
		}else{
			weddingProcess.preUpdate();
			super.dao.update(weddingProcess);
		}
			
			
		
	}
	
}